<%@ page contentType="text/html; charset=utf-8" language="java" errorPage="" %>
<input type="hidden" id="toPage" name="query.toPage" value="<s:property value="query.toPage" />" />
<input type="hidden" id="perPageSize" name="query.perPageSize" value="<s:property value="query.perPageSize" />" />
<input type="hidden" name="query.status" value="<s:property value="query.status"/>" />


<s:if test="query.toPage != 0 && query.totalPage != 0">

	<div class="xt-pages" id="xtPages">
		<s:if test="query.toPage==1">
			<span class="home unabled">首页</span>
			<span class="prev unabled">上一页</span>
		</s:if>
		<s:else>
			<a href="#" class="home" onclick="changePage(1);return false;">首页</a>
			<a href="#" class="prev" onclick="changePage(<s:property value="query.toPage-1"/>);return false;">上一页</a>
		</s:else>
		
		<s:iterator value="pages" status="u">
		
			<s:if test="pages[#u.index]==query.toPage">
				<span class="num-on"><s:property value="pages[#u.index]" /></span>
			</s:if>
			
			<s:elseif test="pages[#u.index]==0">
				<span class="">...</span>
			</s:elseif>
			
			<s:else>
				<a href="#" class="num" onclick="changePage(<s:property value="pages[#u.index]"/>);return false;">
					<s:property value="pages[#u.index]" />
				</a>
			</s:else>
			
		</s:iterator>
		
		
		<s:if test="query.toPage==query.totalPage">
			<span class="next unabled">下一页</span>
			<span class="last unabled">末页</span>
		</s:if>
		<s:else>
			<a href="#" class="next" onclick="changePage(<s:property value="query.toPage + 1"/>);return false;">下一页</a>
			<a href="#" class="last" onclick="changePage(<s:property value="query.totalPage"/>);return false;">末页</a>
		</s:else>
	</div>

</s:if>


<script>

function changePage(page) {

	var reg = /^[0-9]*$/;
	
    if (!reg.test(page) || page<=0) {
        page = 1;
	}
		
    if (page><s:property value="query.totalPage" />) {
        page = <s:property value="query.totalPage" />;
	}

    if(page==$("#toPage").val()){
        return false;
    } 
	
    $("#toPage").val(page);
    $('#searchform').submit();
}

function initPageNum() {
    $("#toPage").val(1);
}

</script>


